package admin.server.feign;

import admin.server.config.FeignConfig;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.*;
import admin.common.vo.ResponseVO;
import admin.common.domain.req.Oauth2LoginReq;

/**
 * 认证服务远程调用
 * Created by zgb on 2020/7/19.
 */
//不用走网关
@FeignClient(name = "AuthService",path ="${services.auth.contextPath}/oauth",url = "${services.auth.ip}:${services.auth.port}",configuration = FeignConfig.class)
public interface AuthFeign {


    @Operation(summary = "Oauth2获取token")
    @PostMapping(value = "/entry", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    public ResponseVO entry(@Schema(name = "Oauth2登录 参数对象")
                                              Oauth2LoginReq oauth2LoginReq
    ) throws HttpRequestMethodNotSupportedException ;

    @Operation(summary = "登出功能")
    @RequestMapping(value = "/logout", method = RequestMethod.POST)
    @ResponseBody
    public ResponseVO logout(@RequestHeader(value = HttpHeaders.AUTHORIZATION) String authHeader) ;


    @Operation(summary = "踢下线")
    @RequestMapping(value = "/kick", method = RequestMethod.POST)
    @ResponseBody
    public ResponseVO kick(String userName) ;




}
